import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '任务书ID',
    align: 'center',
    dataIndex: 'wmTaskbookId'
   },
   {
    title: '项目名称',
    align: 'left',
    dataIndex: 'name'
   },
   {
    title: '项目编码',
    align: 'center',
    dataIndex: 'code'
   },
   {
    title: '负责人',
    align: 'center',
    dataIndex: 'chargeBy'
   },
   {
    title: '进度',
    align: 'center',
    dataIndex: 'progress'
   },
   {
    title: '附件',
    align: 'center',
    dataIndex: 'file',
   },
   {
    title: '进度权重',
    align: 'center',
    dataIndex: 'weight'
   },
   {
    title: '状态',
    align: 'center',
    dataIndex: 'status_dictText'
   },
   {
    title: '当前节点ID',
    align: 'center',
    dataIndex: 'currentNodeId'
   },
   {
    title: '设计师或工艺',
    align: 'center',
    dataIndex: 'designBy'
   },
   {
    title: '调试工程师',
    align: 'center',
    dataIndex: 'debugBy'
   },
   {
    title: '采购完成时间',
    align: 'center',
    dataIndex: 'purchaseEndTime'
   },
   {
    title: '设计完成时间',
    align: 'center',
    dataIndex: 'designEndTime'
   },
   {
    title: '生产完成时间',
    align: 'center',
    dataIndex: 'produceEndTime'
   },
   {
    title: '计划开始时间',
    align: 'center',
    dataIndex: 'planBeginTime'
   },
   {
    title: '计划完成时间',
    align: 'center',
    dataIndex: 'planEndTime'
   },
   {
    title: '实际开始时间',
    align: 'center',
    dataIndex: 'factBeginTime'
   },
   {
    title: '实际完成时间',
    align: 'center',
    dataIndex: 'factEndTime'
   },
   {
    title: '调试开始时间',
    align: 'center',
    dataIndex: 'debugBeginTime'
   },
   {
    title: '调试完成时间',
    align: 'center',
    dataIndex: 'debugEndTime'
   },
   {
    title: '产品物料标识',
    align: 'center',
    dataIndex: 'itemOrProduct_dictText'
   },
   {
    title: '任务类型',
    align: 'center',
    dataIndex: 'type_dictText'
   },
   {
    title: '备注',
    align: 'center',
    dataIndex: 'remark'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '任务书ID',
    field: 'wmTaskbookId',
    component: 'Input',
  },
  {
    label: '项目名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '项目编码',
    field: 'code',
    component: 'Input',
  },
  {
    label: '负责人',
    field: 'chargeBy',
    component: 'Input',
  },
  {
    label: '进度',
    field: 'progress',
    component: 'Input',
  },
  {
    label: '附件',
    field: 'file',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '进度权重',
    field: 'weight',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'status',
    defaultValue: "PREPARE",
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"task_status"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入状态!'},
          ];
     },
  },
  {
    label: '当前节点ID',
    field: 'currentNodeId',
    component: 'Input',
  },
  {
    label: '设计师或工艺',
    field: 'designBy',
    component: 'Input',
  },
  {
    label: '调试工程师',
    field: 'debugBy',
    component: 'Input',
  },
  {
    label: '采购完成时间',
    field: 'purchaseEndTime',
    component: 'InputNumber',
  },
  {
    label: '设计完成时间',
    field: 'designEndTime',
    component: 'InputNumber',
  },
  {
    label: '生产完成时间',
    field: 'produceEndTime',
    component: 'InputNumber',
  },
  {
    label: '计划开始时间',
    field: 'planBeginTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '计划完成时间',
    field: 'planEndTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '实际开始时间',
    field: 'factBeginTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '实际完成时间',
    field: 'factEndTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '调试开始时间',
    field: 'debugBeginTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '调试完成时间',
    field: 'debugEndTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '产品物料标识',
    field: 'itemOrProduct',
    defaultValue: "ITEM",
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"item_or_product"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入产品物料标识!'},
          ];
     },
  },
  {
    label: '任务类型',
    field: 'type',
    defaultValue: "SELF",
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"task_type"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入任务类型!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: '父级节点',
    field: 'pid',
    component: 'JTreeSelect',
    componentProps: {
      dict: "wm_task,name,id",
      pidField: "pid",
      pidValue: "0",
      hasChildField: "has_child",
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  wmTaskbookId: {title: '任务书ID',order: 0,view: 'text', type: 'string',},
  name: {title: '项目名称',order: 1,view: 'text', type: 'string',},
  code: {title: '项目编码',order: 2,view: 'text', type: 'string',},
  chargeBy: {title: '负责人',order: 3,view: 'text', type: 'string',},
  progress: {title: '进度',order: 4,view: 'text', type: 'string',},
  file: {title: '附件',order: 5,view: 'file', type: 'string',},
  weight: {title: '进度权重',order: 6,view: 'text', type: 'string',},
  status: {title: '状态',order: 7,view: 'list', type: 'string',dictCode: 'task_status',},
  currentNodeId: {title: '当前节点ID',order: 8,view: 'text', type: 'string',},
  designBy: {title: '设计师或工艺',order: 9,view: 'text', type: 'string',},
  debugBy: {title: '调试工程师',order: 10,view: 'text', type: 'string',},
  purchaseEndTime: {title: '采购完成时间',order: 11,view: 'number', type: 'number',},
  designEndTime: {title: '设计完成时间',order: 12,view: 'number', type: 'number',},
  produceEndTime: {title: '生产完成时间',order: 13,view: 'number', type: 'number',},
  planBeginTime: {title: '计划开始时间',order: 14,view: 'datetime', type: 'string',},
  planEndTime: {title: '计划完成时间',order: 15,view: 'datetime', type: 'string',},
  factBeginTime: {title: '实际开始时间',order: 16,view: 'datetime', type: 'string',},
  factEndTime: {title: '实际完成时间',order: 17,view: 'datetime', type: 'string',},
  debugBeginTime: {title: '调试开始时间',order: 18,view: 'datetime', type: 'string',},
  debugEndTime: {title: '调试完成时间',order: 19,view: 'datetime', type: 'string',},
  itemOrProduct: {title: '产品物料标识',order: 20,view: 'list', type: 'string',dictCode: 'item_or_product',},
  type: {title: '任务类型',order: 21,view: 'list', type: 'string',dictCode: 'task_type',},
  remark: {title: '备注',order: 22,view: 'textarea', type: 'string',},
};


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
